/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package domain;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import sommm.Element;
import util.Porter;
import util.StringUtil;
import websom.Stopwords;

/**
 *
 * @author Teddy
 */
public class NewsArticle extends Element implements Runnable {

    private String fileName;
    private long itemId;
    private String id;
    private String date;
    private String title;
    private String text;
    private String headline;
    private String dateLine;
    private String copyright;
    private List<String> industryCode;
    private List<String> regionCode;
    private List<String> topicCode;
    private Date dateCreated;
    private String publisher;
    private Date datePublished;
    private String source;
  //  private List<String> words = new LinkedList<String>();

    public NewsArticle() {
        super();
        industryCode = new LinkedList<String>();
        regionCode = new LinkedList<String>();
        topicCode = new LinkedList<String>();
        
    }

    public long getItemId() {
        return itemId;
    }

    public void setItemId(long itemId) {
        this.itemId = itemId;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getHeadline() {
        return headline;
    }

    public void setHeadline(String headline) {
        this.headline = headline;
    }

    public String getDateLine() {
        return dateLine;
    }

    public void setDateLine(String dateLine) {
        this.dateLine = dateLine;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getCopyright() {
        return copyright;
    }

    public void setCopyright(String copyright) {
        this.copyright = copyright;
    }

    public List<String> getRegionCode() {
        return regionCode;
    }

    public void setRegionCode(List<String> regionCode) {
        this.regionCode = regionCode;
    }

    public List<String> getIndustryCode() {
        return industryCode;
    }

    public void setIndustryCode(List<String> industryCode) {
        this.industryCode = industryCode;
    }

    public List<String> getTopicCode() {
        return topicCode;
    }

    public void setTopicCode(List<String> topicCode) {
        this.topicCode = topicCode;
    }

    public Date getDateCreated() {
        return dateCreated;
    }

    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public Date getDatePublished() {
        return datePublished;
    }

    public void setDatePublished(Date datePublished) {
        this.datePublished = datePublished;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }
/*
    public List<String> getWords() {
        return words;
    }
*/
    public void run() {
        Porter stemmer = new Porter();

        text = text.replaceAll(",", " ");
        text = text.replaceAll("\n", " ");
        String w[] = text.split(" ", -1);
        for (String word : w) {
            word = word.toLowerCase().trim();
            if (!word.equals("")) {
                word = stemmer.stripAffixes(word);
                if (!Stopwords.getInstance().getStopwordsList().contains(word)) {
                    if (!word.equals("") && !StringUtil.isNumber(word)) {
                     //   words.add(word);
                        dimensiuni.increment(word);
                    }
                }
            }
        }
    }

    @Override
    public String toString(){
        return dimensiuni.toString();
    }
}
